package cn.com.wangluotongxin.merchants.controller;

import cn.com.wangluotongxin.common.web.AjaxResult;
import cn.com.wangluotongxin.db.pojo.PageData;
import cn.com.wangluotongxin.merchants.dto.GoodsInfoMxDto;
import cn.com.wangluotongxin.merchants.service.IMerchantsGoodsInfoMxService;
import cn.com.wangluotongxin.merchants.vo.GoodsInfoMxVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 商户管理-商品信息明细 前端控制器
 * </p>
 *
 * @author AutoGenerator
 * @since 2024-09-12
 */
@Api(tags = "商户管理-商品信息明细 相关接口")
@RestController
@RequestMapping("/goods/info/mx")
public class MerchantsGoodsInfoMxController {

    @Autowired
    private IMerchantsGoodsInfoMxService goodsInfoMxService;

    @ApiOperation("分页")
    @GetMapping("/page")
    public AjaxResult<PageData<GoodsInfoMxVo>> getPage(GoodsInfoMxDto dto){
        IPage<GoodsInfoMxVo> page = goodsInfoMxService.getPage(dto);
        return AjaxResult.success(PageData.build(page));
    }

    @ApiOperation("发布")
    @PostMapping("/release/{id}")
    public AjaxResult release(@PathVariable("id") Integer id) {

        goodsInfoMxService.release(id);
        return AjaxResult.success("发布成功");
    }

    @ApiOperation("撤回")
    @PostMapping("/recall/{id}")
    public AjaxResult recall(@PathVariable("id") Integer id) {

        goodsInfoMxService.recall(id);
        return AjaxResult.success("撤回成功");
    }
}